#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#include "MyString.h"
#include "DynamicArray.h"
#include "Tool.h"

struct Monster *CreateMonster(const char *name, int HP, int attack)
{
    struct Monster *monster = (struct Monster *)malloc(sizeof(struct Monster));
    if (monster == NULL)
    {
        printf("Create Monster Error!\n");
        return NULL;
    }
    monster->HP = HP;
    monster->attack = attack;
    Initiallize(&monster->name, name);

    monster->x = GetRandNumber(Map_Size);
    monster->y = GetRandNumber(Map_Size);
    
    while (monster->x == 0 && monster->y == 0)
    {
        monster->x = GetRandNumber(Map_Size);
        monster->y = GetRandNumber(Map_Size);
    }

    return monster;
}

void InitMonsters(struct DynamicArray *array)
{
    if (ArrayInit(array) == false)
    {
        return;
    }

    InsertArray(array, CreateMonster("地狱恶魔", 300, 25));
    InsertArray(array, CreateMonster("雷霆巨人", 50, 12));
    InsertArray(array, CreateMonster("雷霆巨人", 50, 12));
    InsertArray(array, CreateMonster("雷霆巨人", 50, 12));
    InsertArray(array, CreateMonster("冰霜蛇", 20, 5));
    InsertArray(array, CreateMonster("冰霜蛇", 20, 5));
    InsertArray(array, CreateMonster("冰霜蛇", 20, 5));
    InsertArray(array, CreateMonster("冰霜蛇", 20, 5));
    InsertArray(array, CreateMonster("冰霜蛇", 20, 5));
}

